//
//  SRAudioPlayerManager
//  EnglishTalk
//
//  Created by huyanming on 15/8/1.
//  Copyright (c) 2015年 Feizhu Tech. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <AVFoundation/AVFoundation.h>
//#import "FZMessageBaseCell.h"
//#import "FZAudioMessageCell.h"
//#import "FZLittleFunChatAudioTableViewCell.h"

typedef void(^SRAudioCompletedBlock)(BOOL finish);
typedef void(^SRAudioProgressBlock)(CGFloat progress);

typedef void(^SRAudioRecorderBeginBlock)(id target);
typedef void(^SRAudioRecorderFailureBlock)(NSString *message);



@interface SRAudioPlayerManager : NSObject

@property (copy, nonatomic) SRAudioProgressBlock audioPlayerTimeBlock;
@property (copy, nonatomic) SRAudioProgressBlock audioPlayerProgressBlock;
@property (copy, nonatomic) SRAudioCompletedBlock audioPlayerCompletedBlock;
@property (assign, nonatomic) CGFloat audioRate;//default is 1.0
@property (strong, nonatomic) NSString *audioFilePath;//当前播放录音的文件路径
@property (strong, nonatomic) NSString *audioFileName;//当前播放录音的文件名

    //录音
@property (copy, nonatomic) SRAudioProgressBlock audioRecorderProgressBlock;
@property (copy, nonatomic) SRAudioCompletedBlock audioRecorderCompletedBlock;
@property (copy, nonatomic) SRAudioRecorderBeginBlock audioRecorderBeginBlock;
@property (copy, nonatomic) SRAudioRecorderFailureBlock audioRecorderFailureBlock;
@property (assign, nonatomic) NSTimeInterval recorderDuration;//录音时长


+ (SRAudioPlayerManager*)sharedInstance;



- (void)setRecordAudioWithFileName:(NSString *)fileName;
- (void)setRecordAudioWithFilePath:(NSString*)filePath;
- (void)setRecordAudioWithFilePath:(NSString*)filePath startTime:(NSTimeInterval)startTime endTime:(NSTimeInterval)endTime;

- (void)setRecordAudioProgress:(CGFloat)progress autoPlay:(BOOL)autoPlay;

- (void)resetLastAudioCellStopPlaying;
- (BOOL)isPlaying;
/**
 *  开始播放
 *
 *   是否播放成功 yes is success
 */
- (BOOL)startPlayRecordAudio;
- (void)pauseRecordAudio;
- (void)stopPlayRecordAudio;

- (void)setAutoScrollProgress:(BOOL)isAuto;
- (NSString *)playingFileName;
    //若本地没有，则下载音频文件
- (void)setRecordAudioWithFileURL:(NSString *)fileURL;

/**
 *  播放语音数据
 *
 */
- (void)playRecordAudioWithData:(NSData*)data;

#pragma mark - Recoder


-(void)prepareToRecorderOutputUrl:(NSString*)filePath;
-(void)beginRecorder;
-(void)beginRecorderForDuration:(NSTimeInterval)duration;
-(void)stopRecorder;
-(void)updateMeters;
- (BOOL)isRecording;





@end
